<%--
  Created by IntelliJ IDEA.
  User: q
  Date: 2021/11/16
  Time: 14:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>02-Ajax跨域.jsp</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                alert(111);
                $.ajax({
                    url : "http://localhost:81/test81",
                    type : "get",
                    data : {},
                    dataType : "json",
                    xhrFields : {
                        //跨域携带cookie，就会造成跨域响应又没办法拿到了
                        withCredentials : true
                    },
                    success : function (result) {
                        console.log(result)
                    },
                    error : function () {
                        alert("error...")
                    }
                })
            })
        })
    </script>
</head>
<body>

    <button id="btn">Ajax访问应用二【81】的test81接口</button>

</body>
</html>
